//
//  BMSDataPersistenceManager.m
//  WDBMS
//
//  Created by YeJary on 2025/5/19.
//

#import "BMSDataPersistenceManager.h"

#define WDGroMoreJsonFileName @"GroMoreConfig"

@implementation BMSDataPersistenceManager

static BMSDataPersistenceManager *_manager = nil;

+ (instancetype)manager {
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        _manager = [[self alloc] init];
        
    });
    return _manager;
}

+ (NSDictionary *)readWDGroMoreSDKConfigFile {
    NSString *filePath = [[NSBundle mainBundle] pathForResource:WDGroMoreJsonFileName ofType:@"json"];
    if (!filePath) {
        NSLog(@"[SDKConfig] 配置文件未找到：%@", WDGroMoreJsonFileName);
        return nil;
    }

    NSData *jsonData = [NSData dataWithContentsOfFile:filePath];
    if (!jsonData) {
        NSLog(@"[SDKConfig] 无法读取文件数据：%@", filePath);
        return nil;
    }

    NSError *error = nil;
    NSDictionary *jsonDict = [NSJSONSerialization JSONObjectWithData:jsonData
                                                             options:NSJSONReadingMutableContainers
                                                               error:&error];
    if (error) {
        NSLog(@"[SDKConfig] JSON 解析失败：%@", error.localizedDescription);
        return nil;
    }

    NSLog(@"[WDGroMore] JSON 配置加载成功：%@", jsonDict);
    return jsonDict;
}

@end
